﻿<!-- *******************************************************************************\
| Copyright (c) 2011, Bashar Al-Rawi                                                |
| All rights reserved.                                                              |
|                                                                                   |
| Redistribution and use in source and binary forms, with or without                |
| modification, are permitted provided that the following conditions are met:       |
|    * Redistributions of source code must retain the above copyright               |
|      notice, this list of conditions and the following disclaimer.                |
|    * Redistributions in binary form must reproduce the above copyright            |
|      notice, this list of conditions and the following disclaimer in the          |
|      documentation and/or other materials provided with the distribution.         |
|    * Neither the name of the <organization> nor the                               |
|      names of its contributors may be used to endorse or promote products         |
|      derived from this software without specific prior written permission.        |
|                                                                                   |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   |
| ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     |
| WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            |
| DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY                |
| DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES        |
| (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      |
| LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND       |
| ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT        |
| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     |
| SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      |
\*********************************************************************************-->
<UserControl x:Class="Arabic.Controls.Key"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converter="clr-namespace:Arabic.Controls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}" MaxWidth="240" HorizontalAlignment="Left" MaxHeight="160" d:DesignHeight="82" d:DesignWidth="48" Width="{Binding Width, Mode=TwoWay}" Height="{Binding Height, Mode=TwoWay}">
    <UserControl.Resources>
        <converter:SubtractFormatter x:Key="SubtractFormatter"/>
    </UserControl.Resources>
    <Canvas Margin="0,0,441,413" MaxWidth="216" Width="{Binding Width}" Height="{Binding Height}">
        <MediaElement Name="me"/>
        <Rectangle Height="{Binding Height, Mode=TwoWay, Converter={StaticResource SubtractFormatter}, ConverterParameter=6}" HorizontalAlignment="Left" Margin="0" Name="rectangle" Stroke="Black" StrokeThickness="0" VerticalAlignment="Top" Width="{Binding Width, Mode=TwoWay, Converter={StaticResource SubtractFormatter}, ConverterParameter=6}" Grid.ColumnSpan="2" Fill="{StaticResource PhoneButtonColor}" Canvas.Left="3" Canvas.Top="2" MaxWidth="220" />

        <TextBlock HorizontalAlignment="Center" Margin="0" Name="textBlock" Text="{Binding Text, Mode=TwoWay}" VerticalAlignment="Stretch" Canvas.Left="2" Canvas.Top="{Binding TextOffset, Mode=TwoWay}" Width="{Binding Width, Mode=TwoWay, Converter={StaticResource SubtractFormatter}, ConverterParameter=0}" TextAlignment="Center" MaxWidth="240" Height="{Binding Height, Mode=TwoWay, Converter={StaticResource SubtractFormatter}, ConverterParameter=0}" FontSize="{Binding FontSize}" Padding="0" TextWrapping="NoWrap">
            <TextBlock.Foreground>
                <SolidColorBrush  Color="{StaticResource PhoneForegroundColor}"/>
            </TextBlock.Foreground>
        </TextBlock>
        <Image x:Name="image" Canvas.Left="0" Canvas.Top="{Binding ImageOffset, Mode=TwoWay}" Height="54" Stretch="None" Width="{Binding Width, Mode=TwoWay, Converter={StaticResource SubtractFormatter}, ConverterParameter=0}" Source="{Binding ImageSource}"/>
        <Button HorizontalAlignment="Left" Name="button" VerticalAlignment="Top" Padding="10,10,10,5" UseLayoutRounding="True" MouseLeftButtonDown="button1_MouseLeftButtonDown" BorderThickness="0" IsHitTestVisible="True" Grid.ColumnSpan="2" FontSize="20" IsEnabled="true" Foreground="{x:Null}" BorderBrush="{x:Null}" Height="{Binding Height, Mode=TwoWay, Converter={StaticResource SubtractFormatter}, ConverterParameter=0}" Background="Transparent" Width="{Binding Width, Mode=TwoWay}" Margin="6,9,0,0" Visibility="Visible" Opacity="0" ClickMode="Hover" Canvas.Left="-7" Canvas.Top="-9" MaxWidth="240" MouseLeave="button_MouseLeave" MouseEnter="button_MouseEnter" />        
    </Canvas>
</UserControl>
